package com.itheima.chapter07.objects;

import java.util.Objects;

public class demo {
    public static void main(String[] args) {
        //public static String toString(对象)  返回参数中对象的字符串表示
        Student s =new Student("小罗同学",50);
        String result = Objects.toString(s);
        System.out.println(result);//com.itheima.chapter07.objects.Student@4554617c
        System.out.println(s.toString());
        //toString重写之后代码更改：Student{name='小罗同学', age=50}

        System.out.println("-----------------------");

        //public static String toString(对象，默认字符串)   返回对象字符串表示形式
        Student s1 =new Student("小花",23);
        String result1 =Objects.toString(s1,"lalallallala");
        System.out.println(result1);//Student{name='小花', age=23}
        Student s2 =null;
        String result2 = Objects.toString(s2, "gagaggaga");
        System.out.println(result2);//gagaggaga

        System.out.println("-----------------------");

        //public static Boolean isNull(对象)  判断对象是否为空
        boolean result3 = Objects.isNull(s2);
        System.out.println(result3);//true
        boolean result4 = Objects.isNull(s1);
        System.out.println(result4);//false

        System.out.println("-------------------");

        //public static Boolean nonNull(对象)  判断对象是否为不空
        boolean b = Objects.nonNull(s1);
        System.out.println(b);//true
        boolean b1 = Objects.nonNull(s2);
        System.out.println(b1);//false

    }
}
